package com.hutra.utils {
	
	public class GSize {
		
		public function GSize() {
		}
		
		public static function FormatSize(size:uint):String {
			if (size < 1024)
				return PadSize(int(size * 100) / 100) + " bytes";
			if (size < 1048576)
				return PadSize(int((size / 1024) * 100) / 100) + "KB";
			if (size < 1073741824)
				return PadSize(int((size / 1048576) * 100) / 100) + "MB";
			return PadSize(int((size / 1073741824) * 100) / 100) + "GB";
		}
		
		public static function FormatPercent(percent:Number):String {
			percent = int(percent);
			return String(percent);
		}
		
		public static function PadSize(size:Number):String {
			var temp:String = String(size);
			var index:int = temp.lastIndexOf(".");
			if (index == -1)
				return temp + ".00";
			else if (index == temp.length - 2)
				return temp + "0";
			else
				return temp;
		}
	}

}
